package cn.itrip.auth.service;

import cn.itrip.utlis.RedisAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @Description : 邮件服务
 * Created by Li on 2020-12-22 14:29:54
 */

@Service
public class MailService {
    @Autowired
    private JavaMailSender javaMailSender;
    @Autowired
    private RedisAPI redisAPI;
    public void send(String to, String subject, String content) {
        SimpleMailMessage mail = new SimpleMailMessage();
        mail.setFrom("1460943193@qq.com");
        mail.setTo(to);
        mail.setSubject(subject);
        mail.setText(content);
        javaMailSender.send(mail);
        redisAPI.setex(to,5*60,content);
        System.out.println("发送成功");
    }
}
